import Taro, { Component,useMemo } from '@tarojs/taro'
import { View, Button, Text,Image } from '@tarojs/components'
import { observer, inject } from '@tarojs/mobx'


import './index.scss'

@inject('counterStore','UserStore')
@observer
class Index extends Component {

  config = {
    navigationBarTitleText: '首页'
  }

  componentWillMount () { }

  componentWillReact () {

  }

  componentDidMount () { }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  increment = () => {
    const { counterStore } = this.props
    counterStore.increment()
  }

  decrement = () => {
    const { counterStore } = this.props
    counterStore.decrement()
  }

  incrementAsync = () => {
    const { counterStore } = this.props
    counterStore.incrementAsync()
  }

  GetSystemInfo=(parms)=>(e)=>{
    //TaroUI.ShowErrorToast("错误")
    const { UserStore } = this.props
    UserStore.ChanageName({name:'星华'})
  }


  render () {
    const { counterStore: { counter } } = this.props
    const {UserStore:{name}} = this.props
    return (
      <View className='index'>
        <Button onClick={this.increment}>+</Button>
        <Button onClick={this.decrement}>-</Button>
        <Button onClick={this.incrementAsync}>Add Async</Button>
        <Button onClick={this.GetSystemInfo('3333')}>测试</Button>
        <Text>{counter}</Text>
        <Text>{name}</Text>
        <Text>{counter}</Text>
      </View>
    )
  }
}

export default Index
